<!DOCTYPE html>
<html lang="en" class="page-fill" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>SPAdmin极速开发框架 - 登录</title>
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="keywords" content="SpringBoot极速开发框架">
<meta name="description" content="SpringBoot极速开发框架">
<link rel="shortcut icon" th:href="@{/images/favicon.ico}"
	type="image/x-icon" />
<link rel="stylesheet" th:href="@{/css/oksub.css}" />
</head>
<body class="page-fill">
	<div class="page-fill" id="login">
		<form class="layui-form">
			<div class="login_face">
				<img th:src="@{/images/logo.png}">
			</div>
			<div class="layui-form-item input-item">
				<!--                    <label for="username">用户名</label>-->
				<input type="text" lay-verify="required" value="admin"
					name="username" placeholder="请输入账号" autocomplete="off"
					id="username" class="layui-input">
			</div>
			<div class="layui-form-item input-item">
				<!--                    <label for="password">密码</label>-->
				<input type="password" lay-verify="required|password" value="111111"
					name="password" placeholder="请输入密码" autocomplete="off"
					id="password" class="layui-input">
			</div>
			<!-- <div class="layui-form-item">
                    <button type="button" id="TencentCaptcha" data-appid="2042633230" data-cbfn="callback" class="layui-btn layui-block" >登录</button>
                </div> -->
			<div class="layui-form-item">
				<button type="button" id="TencentCaptcha" onclick="login()"
					class="layui-btn layui-block">登录</button>
			</div>
			<!-- <div id="wechat" style="display:none">
                    <img th:src="@{/images/wechat.jpg}">
                </div> -->
			<!--               <div class="login-link">-->
			<!--                  <a href="./register.html">注册</a>-->
			<!--                  <a href="./forget.html">忘记密码?</a>-->
			<!--               </div>-->
		</form>
	</div>
	<!-- <script src="https://ssl.captcha.qq.com/TCaptcha.js"></script> -->
	<script th:src="@{/lib/layui/layui.js}"></script>
	<script th:src="@{/lib/common/login.js}"></script>
	<script>
		layui.use([ "form", "okUtils", "okLayer" ], function() {
			form = layui.form;
			$ = layui.jquery;
			var okGVerify = layui.okGVerify;
			var okUtils = layui.okUtils;
			okLayer = layui.okLayer;
			/**
			 * 数据校验
			 */
			form.verify({
				password : [ /^[\S]{6,20}$/, "密码必须6到20位，且不能出现空格" ],
				captcha : function(val) {
					if (verifyCode.validate(val) != "true") {
						return verifyCode.validate(val)
					}
				}
			});
			/**
			 * 表单提交
			 */
			form.on("submit(login)", function(data) {
				return false;
			});
			/**
			 * 表单input组件单击时
			 */
			$("#login .input-item .layui-input").click(
					function(e) {
						e.stopPropagation();
						$(this).addClass("layui-input-focus").find(
								".layui-input").focus();
					});

			/**
			 * 表单input组件获取焦点时
			 */
			$("#login .layui-form-item .layui-input").focus(function() {
				$(this).parent().addClass("layui-input-focus");
			});

			/**
			 * 表单input组件失去焦点时
			 */
			$("#login .layui-form-item .layui-input").blur(function() {
				$(this).parent().removeClass("layui-input-focus");
				if ($(this).val() != "") {
					$(this).parent().addClass("layui-input-active");
				} else {
					$(this).parent().removeClass("layui-input-active");
				}
			})
		});
		function login() {
			$.ajax({
				url : "/sys/login",
				type : "POST",
				data : {
					'username' : $("#username").val(),
					'password' : $("#password").val()
				},
				success : function(result) {
					if (result.code == 0) {
						okLayer.msg.greenTick(result.msg, function() {
							sessionStorage.setItem('username', $("#username")
									.val());
							window.location = "index.html";
						});
					} else {
						//$("#wechat").show();
						okLayer.msg.greenLaugh("账号或密码错误！")
					}
				}
			});
		}
		/* window.callback = function(res){
		    if(res.ret === 0){
		        $.ajax({
		            url:"/sys/login",
		            type: "POST",
		            data : {'username':$("#username").val(),
		                    'password':$("#password").val(),
		                    'ticket':res.ticket,'randstr':res.randstr},
		            success: function (result) {
		                if(result.code==0){
		                    okLayer.msg.greenTick(result.msg, function () {
		                        sessionStorage.setItem('username', $("#username").val());
		                        window.location = "index.html";
		                    });
		                }else{
		                    //$("#wechat").show();
		                    okLayer.msg.greenLaugh("账号或密码错误！")
		                }
		            }
		        });
		    }
		} */
	</script>
	<script>
		window.onload = function() {
			if (window != top) {
				alert("您的账号在另一台设备上登录，若非本人操作，请立即修改密码")
				top.location.href = location.href;
			}
		}
	</script>
</body>
</html>
